home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
BSCPU.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
3KB
|
126 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: bscpu.c
// Title: Base library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains .
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <bs.h>
//----------------------------------------------------------------------------
// Description: Determine CPU type.
// Parameters:
// Returns: 0 = 8086, 2=286, 3=386, ...
// Currently 486+ are not recognized
//----------------------------------------------------------------------------
SIZET FN_E Cpu(void)
{
#if OS_OS2
return 3;
#elif OS_DOS || OS_WINDOWS
_asm {
push sp // Test for 808x, 8018x
pop bx
cmp sp,bx
jz cpu286 // Not one of earlier 808x or 8018x
mov bx,0ffffh
mov cl,33
shl bx,cl
or bx,ax
jnz cpu186
}
return 0; // 8086
cpu186:
return 1; // 80186
cpu286:
_asm {
pushf // Test for 80286
pop bx
or bx,4000h
push bx
popf
pushf
pop bx
test bx,4000h
jnz cpu386
}
return 2; // 286
cpu386:
return 3; // 386
#else
return 3; // Unix
#endif
}
//----------------------------------------------------------------------------
// Description: Determine CPU type.
// Parameters:
// Returns: 0 = 8086, 2=286, 3=386, ...
// Currently 486+ are not recognized
//----------------------------------------------------------------------------
PCSZ FN_E CpuName(void)
{
static PCSZ apcsz[] = { "8086", "80186", "80286", "80386", "80486", "80586" };
SIZET cCpu = Cpu();
Assert(cCpu <= 5);
return apcsz[cCpu];
}
//----------------------------------------------------------------------------
// Description: Run standard test suite
// Parameters: sTest Test to run.
// 0 Run all default tests (except).
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
#if COMPILE_TEST
BOOL FN CpuTest(SHORT sTest)
{
NOTUSED(sTest);
Output("CPU is a %s\n", CpuName());
return TRUE;
}
#endif
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------